import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

# 邮件配置
sender = 'your_email@example.com'
receiver = 'receiver@example.com'
subject = '自动化办公测试邮件'
body = '这是一封通过 Python 自动发送的邮件。'

# 创建邮件
msg = MIMEMultipart()
msg['From'] = sender
msg['To'] = receiver
msg['Subject'] = subject
msg.attach(MIMEText(body, 'plain'))

# 发送邮件
with smtplib.SMTP('smtp.example.com', 587) as server:
    server.starttls()
    server.login(sender, 'your_password')
    server.send_message(msg)